class Pool {
    private static poolList = {};
    /**
     * 获取对象
     * @param clz 对象类名
     */
    public static getItem<T>(clz: { new (): T }): T {
        let pool = (this.poolList[clz["name"]] || (this.poolList[clz["name"]] = []));
        if (pool.length) {
            return pool.pop();
        }
        let obj: any = new clz();
        obj.poolKey = clz["name"];
        return obj;
    }

    /**
     * 回收对象
     * @param ins 对象实例
     */
    public static recover(ins: any) {
        this.poolList[ins.poolKey] && this.poolList[ins.poolKey].push(ins);
    }

    /**清理 */
    public static clear(clz: any, funName: string = null) {
        if (this.poolList[clz.name]) {
            this.poolList[clz.name] = null;
            delete this.poolList[clz.name];
        }
    }
}